<?php

namespace App\Services;

use App\Models\BaseModel;
use App\Models\TradeCate;

class TradeCateService extends BaseService
{
    public function list()
    {
        // 设置对象
        $model = TradeCate::query();
        // 状态
        $model = $model->where('status', BaseModel::STATUS_ENABLE);
        // 获取列表
        $list = $model
            ->orderBy('sort', 'desc')
            ->orderBy('id', 'desc')
            ->get(['id', 'cate_name', 'cate_img'])
            ->toArray();

        foreach ($list as &$item) {
            $item['cate_img'] = storage($item['cate_img']);
        }

        return $list;
    }
}
